package com.taobao.api.request;

import java.util.Map;

import com.taobao.api.ApiRuleException;
import com.taobao.api.TaobaoRequest;
import com.taobao.api.internal.util.RequestCheckUtils;
import com.taobao.api.internal.util.TaobaoHashMap;
import com.taobao.api.response.TaobaokeCaturlGetResponse;

/**
 * TOP API: taobao.taobaoke.caturl.get request
 * 
 * @author auto create
 * @since 1.0, 2013-08-03 16:51:00
 */
public class TaobaokeCaturlGetRequest implements TaobaoRequest<TaobaokeCaturlGetResponse> {

  private Map<String, String> headerMap = new TaobaoHashMap();
  private TaobaoHashMap       udfParams;                      // add
                                                              // user-defined
                                                              // text parameters
  private Long                timestamp;

  /**
   * 标准商品后台类目id。该ID可以通过taobao.itemcats.get接口获取到。
   */
  private Long                cid;

  /**
   * 推广者的淘宝会员昵称.注：这里指的是淘宝的登录会员名
   */
  private String              nick;

  /**
   * 自定义输入串.格式:英文和数字组成;长度不能大于12个字符,区分不同的推广渠道,如:bbs,表示bbs为推广渠道;blog, 表示blog为推广渠道.
   */
  private String              outerCode;

  /**
   * 用户的pid,必须是mm_xxxx_0_0这种格式中间的"xxxx".
   * 注意nick和pid至少需要传递一个,如果2个都传了,将以pid为准,且pid的最大长度是20
   */
  private Long                pid;

  /**
   * 关键词
   */
  private String              q;

  public void setCid(Long cid) {
    this.cid = cid;
  }

  public Long getCid() {
    return this.cid;
  }

  public void setNick(String nick) {
    this.nick = nick;
  }

  public String getNick() {
    return this.nick;
  }

  public void setOuterCode(String outerCode) {
    this.outerCode = outerCode;
  }

  public String getOuterCode() {
    return this.outerCode;
  }

  public void setPid(Long pid) {
    this.pid = pid;
  }

  public Long getPid() {
    return this.pid;
  }

  public void setQ(String q) {
    this.q = q;
  }

  public String getQ() {
    return this.q;
  }

  public Long getTimestamp() {
    return this.timestamp;
  }

  public void setTimestamp(Long timestamp) {
    this.timestamp = timestamp;
  }

  public String getApiMethodName() {
    return "taobao.taobaoke.caturl.get";
  }

  public Map<String, String> getTextParams() {
    TaobaoHashMap txtParams = new TaobaoHashMap();
    txtParams.put("cid", this.cid);
    txtParams.put("nick", this.nick);
    txtParams.put("outer_code", this.outerCode);
    txtParams.put("pid", this.pid);
    txtParams.put("q", this.q);
    if (this.udfParams != null) {
      txtParams.putAll(this.udfParams);
    }
    return txtParams;
  }

  public void putOtherTextParam(String key, String value) {
    if (this.udfParams == null) {
      this.udfParams = new TaobaoHashMap();
    }
    this.udfParams.put(key, value);
  }

  public Class<TaobaokeCaturlGetResponse> getResponseClass() {
    return TaobaokeCaturlGetResponse.class;
  }

  public void check() throws ApiRuleException {
    RequestCheckUtils.checkNotEmpty(cid, "cid");
    RequestCheckUtils.checkMinValue(cid, 0L, "cid");
  }

  public Map<String, String> getHeaderMap() {
    return headerMap;
  }
}
